class Solution:
    def longestCommonPrefix(self, strs: List[str]) -> str:
        if not strs:
            return ''
        for i in range(len(strs[0])):
            for j in range(len(strs)):
                if strs[j][:i+1] != strs[0][:i+1]:
                    return strs[0][:i]
        else:
            return strs[0]
        return ""